package org.woozoo.xhtml.unittests.wordpresssuite
{
	import org.flexunit.asserts.assertTrue;
	import org.flexunit.async.Async;
	import org.woozoo.xhtml.core.base.event.DocumentEvent;
	import org.woozoo.xhtml.wordpress.WPAPI;
	import org.woozoo.xhtml.wordpress.theme.WPWoozoxTheme;
	
	public class WPPostCase
	{
		public var api : WPAPI = WPAPI.getInstance();
		
		[Test(async, order=1)]
		public function setupAPI() : void {
			api.useEvent = true;			
			api.theme = new WPWoozoxTheme();
			
			api.setup('http://projects.first-department-of-informatics.com/woozox/wp/');
			api.addEventListener(DocumentEvent.COMPLETE, Async.asyncHandler(this, __completeHandler, 1000, null, __timeOutHandler), false, 0, true);
			api.addEventListener(DocumentEvent.ERROR, Async.asyncHandler(this, __errorHandler, 1000, null, __timeOutHandler));
		}
		
		protected function __timeOutHandler(passThroughData : Object) : void {
			trace('__timeOutHandler');
//			assertTrue(false);
		}
		
		protected function __completeHandler(e : DocumentEvent, passThroughData : Object) : void {
			trace('__completeHandler');
			assertTrue(true);
		}
		
		protected function __errorHandler(e : DocumentEvent, passThroughData : Object) : void {
			trace('__errorHandler');
			assertTrue(false);
		}
		
		[Test(order=2)]
		public function findElementWithDivId() : void {
			var t : String = api.blogTitle;
			var d : String = api.blogDescription;
			assertTrue(t == "Woozox Blog");
			assertTrue(d == "Just another WordPress weblog");
			//assertTrue(api.categories.length == 4)
		}
	}
}